/**
 *@NApiVersion 2.x
 *@NScriptType ClientScript
 */
define(['N/record', 'N/ui/dialog', 'N/search'], function (record, dialog, search) {

    function saveRecord(context) {
        try {
            for (var i = 0; i < context.currentRecord.getLineCount('line'); i++) {
                context.currentRecord.selectLine('line', i);
                var accounttype = context.currentRecord.getCurrentSublistValue('line', 'accounttype');
                var cashflowitem = context.currentRecord.getCurrentSublistValue('line', 'custcol_cseg_cn_cfi');
                if (accounttype === 'Bank' && cashflowitem.length === 0) {
                    dialog.alert({title: "提示", message: "第" + (i + 1) + "行,银行类科目必须指定现金流量表!"});
                    return false;
                }
            }
        } catch (e) {
            log.error('saveRecord error:', JSON.stringify(e));
        }

        return true;
    }


    return {
        saveRecord: saveRecord
    };
});